package it.gestoreContratti.gui.frames;

import it.gestoreContratti.entity.Specifica;
import it.gestoreContratti.gui.panels.ModificaSpecificaPanel;
import it.gestoreContratti.gui.panels.VisualizzaSpecificheContrattoPanel;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

public class ModifcaSpecificaFrame extends JFrame {


	private static final long serialVersionUID = 2829336210312473606L;
	private JPanel contentPane;
	private VisualizzaSpecificheContrattoPanel pannello;	


	public ModifcaSpecificaFrame(VisualizzaSpecificheContrattoPanel panel, Specifica spec) {
		this.pannello = panel;
		
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {				
				pannello.refresh();				
			}
		});
		setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		GridBagLayout gbl_contentPane = new GridBagLayout();
		gbl_contentPane.columnWidths = new int[]{0, 0};
		gbl_contentPane.rowHeights = new int[]{0, 0};
		gbl_contentPane.columnWeights = new double[]{1.0, Double.MIN_VALUE};
		gbl_contentPane.rowWeights = new double[]{1.0, Double.MIN_VALUE};
		contentPane.setLayout(gbl_contentPane);
		
		ModificaSpecificaPanel modificaSpecificaPanel = new ModificaSpecificaPanel(pannello.getContratto(), pannello.getDatabaseController(), spec);
		GridBagConstraints gbc_modificaSpecificaPanel = new GridBagConstraints();
		gbc_modificaSpecificaPanel.fill = GridBagConstraints.BOTH;
		gbc_modificaSpecificaPanel.gridx = 0;
		gbc_modificaSpecificaPanel.gridy = 0;
		contentPane.add(modificaSpecificaPanel, gbc_modificaSpecificaPanel);
	}

}
